#!/bin/bash 
set -e


TMP=${TMP:-/tmp/work}
LOG=${LOG:-$HOME/logs/stage4}
SRC=${SRC:-/sources}

name=glib
version=2.66.6

rm -rf $TMP
mkdir -p $TMP $LOG

tar xf $SRC/$name-$version.tar.xz -C $TMP

{ time \
   {

    cd $TMP/$name-$version
    
	patch -Np1 -i $SRC/$name-$version-skip_warnings-1.patch

	mkdir build
	cd    build

	meson --prefix=/usr      \
	      -Dman=true         \
	      -Dselinux=disabled \
	      -Dgtk_doc=true     \
	      ..
	ninja

	ninja install

	mkdir -p /usr/share/doc/$name-$version
	cp -r ../docs/reference/{NEWS,gio,glib,gobject} /usr/share/doc/$name-$version

    }
} 2>&1 | tee $name.log
    
[ $PIPESTATUS = 0 ] && mv $name.log $LOG || exit $PIPESTATUS

rm -fr $TMP
